package cn.zhf.shop.service.impl;

import cn.zhf.shop.entity.Bank;
import cn.zhf.shop.entity.Message;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import cn.zhf.shop.mapper.AdMapper;
import cn.zhf.shop.entity.Ad;
import cn.zhf.shop.service.AdService;

import java.util.List;

@Component
public class AdServiceImpl implements AdService {

    @Resource
    private AdMapper adMapper;

    @Override
    public Message deleteByPrimaryKey(Integer adId) {
        return Message.success(null).add(adMapper.deleteByPrimaryKey(adId));
    }

    @Override
    public Message insert(Ad record) {
        return adMapper.insert(record) > 0 ? Message.success(null) : Message.fail(null);
    }

    @Override
    public Message<Ad> selectByPrimaryKey(Integer adId) {
        Ad refund = adMapper.selectByPrimaryKey(adId);
        return refund == null ? Message.fail("无记录") : Message.success(null).add(refund);
    }


    @Override
    public Message updateByPrimaryKey(Ad record) {
        return adMapper.updateByPrimaryKey(record) > 0 ? Message.success("更新成功" + record.getAdId()) : Message.fail("更新失败");
    }

    @Override
    public Message<List<Ad>> selectAll() {
        List<Ad> refund = adMapper.getAll();
        return refund == null ? Message.fail("无记录") : Message.success(null).add(refund);
    }

    @Override
    public Message<List<Ad>> selectAllSelected() {
        List<Ad> refund = adMapper.getAllSelected();
        return refund == null ? Message.fail("无记录") : Message.success(null).add(refund);
    }

    @Override
    public int insertSelective(Ad record) {
        return adMapper.insertSelective(record);
    }

    @Override
    public int updateByPrimaryKeySelective(Ad record) {
        return adMapper.updateByPrimaryKeySelective(record);
    }
}


